package pl.edu.uj.tcs.hkextended;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class GoogleXMLFactory implements XMLFactory {
	public String get(CharSequence txt){
		try{
			URL url = new URL("http://google.com/complete/search?output=toolbar&q="+txt.toString());
			URLConnection conn = url.openConnection();
			BufferedReader in = new BufferedReader(
                    new InputStreamReader(
                    conn.getInputStream()));
			StringBuilder content = new StringBuilder();
			String inputLine;
			while ((inputLine = in.readLine()) != null) 
				content.append(inputLine);
			in.close();
			return content.toString();
		}catch(Exception e){
			return null;
		}
	}
}
